from pyfbsdk import *
lCube = FBModelCube("Cube")
lCube.Show = True;
lSystem = FBSystem()
lSystem.CurrentTake.CreateNewLayer()
lCount = lSystem.CurrentTake.GetLayerCount()
lSystem.CurrentTake.GetLayer(lCount-1).Name= "PythonLayer1"
lSystem.CurrentTake.GetLayerByName("PythonLayer1").Weight = 50;
lSystem.CurrentTake.GetLayerByName("PythonLayer1").LayerMode = FBLayerMode.kFBLayerModeOverride;
lSystem.CurrentTake.SetCurrentLayer(lCount-1)
Node = lCube.AnimationNode.Nodes[0]
for lNode in Node.Nodes:
lNode.FCurve.KeyAdd(FBTime(0,0,0,0), 0)
lCube.Translation.GetAnimationNode().KeyAdd(FBTime(0,0,0,10), 20)
lCube.Rotation.GetAnimationNode().Nodes[0].FCurve = lCube.Translation.GetAnimationNode().Nodes[0].FCurve
lCube.Translation.GetAnimationNode().SetCandidate([10, 10, 10])
lCube.Translation.GetAnimationNode().KeyCandidate()
lSystem.CurrentTake.CreateNewLayer()
lCount = lSystem.CurrentTake.GetLayerCount()
lSystem.CurrentTake.GetLayer(lCount-1).Name= "PythonLayer2"
lSystem.CurrentTake.SetCurrentLayer(lCount-1)
for lNode in Node.Nodes:
lNode.FCurve.KeyAdd(FBTime(0,0,0,20), 15)
del( lNode )
lCube.Translation.GetAnimationNode().KeyAdd(FBTime(0,0,0,20), 11)
lCube.Rotation.GetAnimationNode().Nodes[0].FCurve = lCube.Translation.GetAnimationNode().Nodes[0].FCurve
lCube.Translation.GetAnimationNode().SetCandidate([30, 30, 30])
lCube.Translation.GetAnimationNode().KeyCandidate()
lSystem.CurrentTake.CreateNewLayer()
lCount = lSystem.CurrentTake.GetLayerCount()
ParentLayer = lSystem.CurrentTake.GetLayer(lCount-2)
NewChildLayer = lSystem.CurrentTake.GetLayer(lCount-1)
NewChildLayer.Name= "child of PythonLayer2"
ParentLayer.AddChildLayer(NewChildLayer)
print(ParentLayer.GetChildCount())
ParentLayer.SelectLayer(True, True)